
from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response

from rest_framework.viewsets import ModelViewSet
from django.contrib.auth.models import Group, Permission

from meiduo_admin.serializers.groups import GroupSerializer
from meiduo_admin.serializers.permissions import PermissionSerializer
from meiduo_admin.utils import PageNum


class GroupView(ModelViewSet):
    queryset = Group.objects.all()
    serializer_class = GroupSerializer
    pagination_class = PageNum
    permission_classes = [IsAdminUser]


    # 获取权限简单信息
    def simple(self,request):
        pers=Permission.objects.all()
        ser=PermissionSerializer(pers,many=True)
        return Response(ser.data)
